home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9067 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: user1.mnsinc.com!huang
  2. From: huang@mnsinc.com (Szu-Wen Huang)
  3. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1
  4. Subject: Re: GOTO controversy
  5. Followup-To: comp.lang.misc,comp.lang.c,comp.lang.pl1
  6. Date: 7 Mar 1996 02:01:05 GMT
  7. Organization: Monumental Network Systems
  8. Message-ID: <4hlg11$dd7@news1.mnsinc.com>
  9. References: <rcshlds.1.000A6705@mailserv.mta.ca> <Dn8pJ8.nqs@emi.net> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net>
  10. NNTP-Posting-Host: user1.mnsinc.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. John Noland (sinan@cyberramp.net) wrote:
  14.  
  15. [snip]
  16. :  DON'T use a goto unless it's the only solution to the problem.
  17. :  You have many alternatives to a goto in your above code. 
  18.  
  19. Wrong.  'goto' will never be the only solution.  When the 'goto'
  20. solution is more elegant than the other choices (which is entirely
  21. possible), use 'goto'.
  22.  
  23. :  A subroutine should have at most one label.
  24.  
  25. Arbitrary number.  Does a subroutine with exactly *two* labels
  26. automatically and magically become unreadable?
  27.  
  28. :  All goto's should be above that label in the code.
  29.  
  30. Above?  You mean all 'goto's should be forward jumps?  Why?
  31.  
  32. :  The label should be in the same code block or at a more outer
  33. :  nesting level than the goto itself.
  34.  
  35. : Your code could be easily reorganized to not use a goto.
  36.  
  37. That's the point against using 'goto's.  Realize however that a
  38. good engineer is usually smarter than blind guidelines.  The
  39. rules you raised have obvious drawbacks.  Personally, the rule
  40. I impose upon myself is: "If you use a 'goto', you better have
  41. a damn good reason for it and be prepared to explain why all
  42. other constructs make the program uglier."
  43.